import { defineStore } from 'pinia'
import { ref } from 'vue';

export const useMeanStore = defineStore('mean', () => {
  // 菜单数据
  const menuList = ref([]) as any
  const openeds = ref([]) as any
  // 权限数据
  const permList = ref([])
  const hasRoute = ref(false)
  
  const changeRouteStatus = (state: any) => {
    hasRoute.value = state
    window.localStorage.setItem("hasRoute", state)
  }
  const setMenuList = (menus: any) => {
    if (menus) {
      openeds.value[0] = menus[0].path
      menuList.value = menus
      console.log(menuList.value, '路由')
    }

  }
  const setPermList = (authoritys: any) => {
    permList.value = authoritys
  }
  const setOpeneds = (params: any) => {
    openeds.value[0] = params
  }
  return {
    persist: true,
    menuList,
    permList,
    hasRoute,
    openeds,
    changeRouteStatus,
    setMenuList,
    setPermList,
    setOpeneds
  }
})